<?php

namespace App\Resource;

use App\Model\Banner;
use Hyperf\Resource\Json\ResourceCollection;

class RoleCollection extends ResourceCollection
{
    /**
     * Transform the resource collection into an array.
     *
     * @return array
     */
    public function toArray(): array
    {
        return parent::toArray();
    }

    public function toListApi()
    {
        $data = [];
        /** @var Banner $v */
        foreach ($this as $v) {
            $data[] = [
                'id' => $v->id,
                'name' => $v->name ?? '',
                'status' => $v->status ?? '',
                'status_text' => $v->status_text,
                'manager' => $v->manager->name ?? '',
                'create_time' => $v->create_time ? $v->create_time->toDateTimeString() : '',
            ];
        }

        return $data;
    }
}
